<?php

/**
 * 文章管理控制器
 * Class ArcController
 */
class ArcController{
    /**
     * 异步留言添加
     */
    public function add(){
        $data = include './data.php';
        $_POST['sendTime'] = date('Y-m-d',time());
        $data[] = $_POST;
        file_put_contents('./data.php',"<?php \r\nreturn " . var_export($data,true) . "\r\n?>");
        $id = max(array_keys($data));
        $_POST['id'] = $id;
        echo json_encode($_POST);
    }
    public function del(){
        $data = include './data.php';
        $id = $_POST['i'];
        unset($data[$id]);
        file_put_contents('./data.php',"<?php \r\nreturn " . var_export($data,true) . "\r\n?>");

    }
}